<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    div{width: 200px;height: 200px;background: cadetblue;position: absolute;}
    </style>
</head>
<body>
    <div></div>
    <script>
    var box=document.getElementsByTagName("div")[0]
    document.onkeydown=function(e){
        if(e.keyCode==37){
            box.style.left=box.offsetLeft-100+"px"
        }
        else if(e.keyCode==38){
            box.style.top=box.offsetTop-100+"px"
        }
        else if(e.keyCode==39){
            box.style.left=box.offsetLeft+100+"px"
        }
        else if(e.keyCode==40){
            box.style.top=box.offsetTop+100+"px"
        }
    }
    </script>
</body>
</html>